package com.gl.user.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.cloud.utils.ResultHelper;
import com.gl.user.service.AppUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
public class UserController {

    @Autowired
    private AppUserService appUserService;


    @GetMapping(value = "/user/o/username", params = "username")
    public ResultHelper findByUsername(String username) {
        return ResultHelper.succeed(appUserService.findByUsername(username));
    }


    /**
     * 用户查询
     */
    @GetMapping("/users")
    public ResultHelper findUsers(
            @RequestParam(name = "current", defaultValue = "1", required = false) Integer current,
            @RequestParam(name = "size", defaultValue = "10", required = false) Integer size) {
        Map<String, Object> params = new HashMap<>();
        return ResultHelper.succeed(appUserService.findUsersByPage(new Page<>(current,size),params));
    }



}
